package com.study.english.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.study.english.context.SecurityContextHolder;
import com.study.english.pojo.vo.SysVideoTypeVo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;
import java.util.List;

import org.springframework.beans.BeanUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.study.english.domain.SysVideoType;
import com.study.english.service.ISysVideoTypeService;
import com.study.english.mapper.SysVideoTypeMapper;
import org.springframework.stereotype.Service;

/**
 * @author wf
 * @description 针对表【sys_video_type(学习视频类型)】的数据库操作Service实现
 * @createDate 2024-03-11 15:56:35
 */
@Service
public class SysVideoTypeServiceImpl extends ServiceImpl<SysVideoTypeMapper, SysVideoType>
        implements ISysVideoTypeService {

    @Autowired
    private ISysVideoTypeService sysVideoTypeService;


    @Override
    public void addSysVideoType(SysVideoTypeVo sysVideoTypeVo) {
        SysVideoType sysVideoType = new SysVideoType();
        BeanUtils.copyProperties(sysVideoTypeVo, sysVideoType);
        sysVideoType.setIsDelete(0);
        sysVideoType.setUserId(SecurityContextHolder.getUserId());
        sysVideoType.setCreateTime(new Date());
        sysVideoTypeService.save(sysVideoType);
    }

    @Override
    public IPage<SysVideoTypeVo> getSysVideoTypePageList(IPage<SysVideoTypeVo> page, SysVideoTypeVo sysVideoTypeVo) {
        return this.baseMapper.getSysVideoTypePageList(page, sysVideoTypeVo);
    }


    @Override
    public List<SysVideoTypeVo> getSysVideoTypeList(SysVideoTypeVo sysVideoTypeVo) {
        return this.baseMapper.getSysVideoTypeList(sysVideoTypeVo);

    }

    @Override
    public SysVideoType getSysVideoTypeById(String id) {
        return sysVideoTypeService.getById(id);
    }


    @Override
    public void delSysVideoType(String id) {
        sysVideoTypeService.removeById(id);
    }


    @Override
    public void updateSysVideoType(SysVideoTypeVo sysVideoTypeVo) {
        SysVideoType sysVideoType = new SysVideoType();
        BeanUtils.copyProperties(sysVideoTypeVo, sysVideoType);
        sysVideoTypeService.updateById(sysVideoType);
    }
}




